<?php
namespace Model;
/**
 * Created by PhpStorm.
 * User: yanshaopeng
 * Date: 2018/9/11
 * Time: 15:37
 */

class RedisModel{
    protected  $_redis;
    protected static $_instance;
    public function __construct()
    {
        $servers = C('REDIS_MODEL_DEFINE');
        if(C('REDIS_CLUSTER')){
            $this->_redis = new \RedisCluster('NULL',$servers);
        }else{
            $this->_redis = new \Redis();
            $this->_redis->connect($servers['host'],$servers['port']);
        }
    }

    static public function getDb(){
        if(!(self::$_instance instanceof self)){
            self::$_instance = new self();
        }
        return self::$_instance;
    }
    public function getConnect(){
        return $this->_redis;
    }

}